package com.oa.android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.oa.android.R;
import com.oa.android.entry.Gongdan;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by zouqh on 2016/6/19.
 */
public class GongdAdapter extends BaseAdapter {

    private Context context;
    private List<Gongdan> personList;

    public GongdAdapter(Context context, List<Gongdan> personList) {
        this.context = context;
        this.personList = personList;
    }

    @Override
    public int getCount() {
        return personList.size();
    }

    @Override
    public Object getItem(int position) {
        return personList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.gongd_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.khbh.setText("客户编号："+personList.get(position).getKHBM());
        viewHolder.khxm.setText("客户姓名："+personList.get(position).getKHXM());
        viewHolder.lxdh.setText("联系电话："+personList.get(position).getLXDH());
        viewHolder.gdzt.setText("工单状态："+personList.get(position).getGDZTNAME());
        viewHolder.khdz.setText("客户地址："+personList.get(position).getKHDZ());
        return convertView;
    }


    static class ViewHolder {
        @InjectView(R.id.khbh)
        TextView khbh;
        @InjectView(R.id.khxm)
        TextView khxm;
        @InjectView(R.id.lxdh)
        TextView lxdh;
        @InjectView(R.id.gdzt)
        TextView gdzt;
        @InjectView(R.id.khdz)
        TextView khdz;

        ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
